home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / qbsub10.arc / QBSUB.TXT < prev    next >
Encoding:
Text File  |  1986-06-25  |  7.5 KB  |  136 lines

  1. QBSUB.TXT -- Personal comments about using QuickBASIC        25 June 86
  2.         by David L. Poskie     (608) 274-9560
  3.                   7118 Raymond Rd. Madison, WI 53719
  4.  
  5.     Introduction:
  6.     This note accompanies QBSUB10.ARC, a series of utility subroutines
  7.     to be used in MS QuickBASIC programming.  I hope they are useful
  8.     to other programmers, and that others who are not using QuickBASIC
  9.     will look at the code.  It's not PASCAL, but it's not the old
  10.     BASIC, either -- it's QuickBASIC !
  11.  
  12.     >> Overview:
  13.     First, I do what I do quite well, but I am not an expert at using
  14.     or understanding QBasic (bear with this shorter form). I hope others
  15.     who know more will help me with their criticism and suggestions.
  16.     This note is not only about QBSUBnn.ARC -- it is about QBasic and
  17.     some of the other programs I am using. First, there is a file named
  18.     QBSUBDMO.ARC, which contains many programs that demonstrate using
  19.     the subroutines in QBSUB10.ARC. These require QBSUB10.ARC. Then
  20.     there is a file of my utility subroutines, QBUTIL.ARC. In here are
  21.     two of my utility programs, RLIN.ASC & FOX.ASC. RLIN is a modified
  22.     version of Microsoft's REMLINE.BAS, which is furnished with each
  23.     copy of QuickBASIC. RLIN removes unnecessary line numbers from 
  24.     conventional BASIC programs. In RLIN, program format and variable
  25.     names have been changed to be compatible with my subroutines files.
  26.     FOX is a program I've written to break down conventional BASIC
  27.     programs, formatting them in the looser style permitted by QBasic.
  28.     You don't have to be a QBasic programmer to find a use for FOX. It
  29.     can display any ASCII-saved BASIC program in a looser format, to
  30.     help you understand what is going on. FOX uses the subroutines in
  31.     QBSUB10.ARC. Finally, there is QBX.EXE, a program written by
  32.     Vernon Buerg, et.al.. QBX takes an unlined QBasic program and adds
  33.     line numbers, then produces a cross-reference of the program. The
  34.     combination of RLIN, FOX, & QBX are my mainstay for converting
  35.     BASIC programs to QuickBASIC, and vice-versa.  Yes, there are times
  36.     I want to work on a QBasic routine in the interpreter. For short
  37.     hacks and experiments, it is often much faster in interpreter than 
  38.     to go through editing in WordStar, compilation with BASCOM, and
  39.     linking with LINK. Troubleshooting is also often best done with line
  40.     numbers. To be able to work in interpreter or compiler gives a great
  41.     deal of flexibility and power to QBasic users.
  42.  
  43.     >> My Personal Style of QuickBASIC programming:
  44.     I like working with QBasic very much. The freedom of layout can
  45.     result in code that is far easier to write and to understand than
  46.     code in standard BASIC. The ability to use long variable names also
  47.     helps, provided the names are well chosen. Take a look at my time
  48.     simulation program -- SIMTIME.ASC. I think it is beautiful. MNULIN
  49.     is pretty, too. None of these are as good looking as the best PASCAL
  50.     programs I've seen, but they are a big improvement over BASIC.
  51.  
  52.     I would really appreciate looking at how others code in QBASIC.
  53.     The rules are rather open; much of my form comes from my own
  54.     preferences for layout. Then there is the naming of variables and
  55.     lines -- that, too, is my invention, borrowing heavily from my
  56.     assembly language preferences. My preference is to comment in
  57.     mixed case, and to program in CAPS. But QuickBASIC allows you to
  58.     write code in lower case, the preference of many PASCAL and C
  59.     programmers. Notice how heavily you can comment the code and how
  60.     flexible you can be in where you place the comments. A short time
  61.     ago, I programmed completely in upper case, but have grown fond of
  62.     naming my variables and procedures in mixed case.  The compiler 
  63.     is blind to case in these instances, though, but it aids readability. 
  64.  
  65.     I have my own convention for setting the file extensions;
  66.     I use BAS to designate a program that will run in BASICA, ASC to
  67.     designate a program that will run only in QuickBASIC, and SUB to
  68.     designate a QuickBASIC subroutine that must be $INCLUDE'ed in the
  69.     calling program. In general, ASCII-saved BAS files will also work
  70.     in QuickBASIC, but many BASIC programs need modification. About the
  71.     only thing QuickBASIC will not do is BLOAD, but CALL seems to work
  72.     fine in place of it.
  73.  
  74.     >> How I convert other's BASICA programs:
  75.     First, I strip out unneeded line numbers from an ASCII-saved
  76.     conventional program. For this I use RLIN. After filtering through
  77.     RLIN, I immediately try to compile the program with BASCOM. This
  78.     normally pukes out a bunch of errors that I write down. RLIN
  79.     sometimes removes line numbers that are needed (I can't figure why).
  80.     BASCOM catches this and, at this time, it is relatively easy to 
  81.     go into the file and replace the mistakenly stripped line numbers.
  82.     Then I make the changes noted from the compiler error messages. It
  83.     gets a bit hazy here, but I'm working to the point where the program
  84.     will compile without any error messages. Once I get here, I do
  85.     something that will make it all much easier. I run it through FOX,
  86.     my QBasic program that will take what came from RLIN and strips out
  87.     the executable statements, one per line. Then I begin the process of 
  88.     formatting and commenting the code.  I have taken very complicated
  89.     programs written by others with no comments and made sense of them
  90.     with this technique.  You'll be surprised how much more understandable
  91.     the code is when it is spread out and formatted. Then I begin to 
  92.     replace line numbers with sensible names, mebbe changing variable
  93.     names in the same way. I start separating out all the subroutines,
  94.     getting them tight and pretty, finally putting them in the best spot.
  95.     Then I begin to search the code for chances to make more subroutines,
  96.     eliminating redundant code. While I'm doing this, I'm looking to
  97.     speed up and simplify the code, moving and changing it, eliminating
  98.     variable names that could be combined in another general purpose
  99.     variable. This takes experience, and I've made a lot of mistakes to
  100.     have earned the experience.  It's fun, though, like working a
  101.     crossword puzzle. By this time, I am familiar enough with the code
  102.     that I am enhancing it -- searching to improve its feel, function,
  103.     look, performance. Always learning from what someone else has done.
  104.  
  105.     >> How I troubleshoot in QuickBASIC:
  106.     If I run into any snags, I can use QBX to reenter linenumbers and
  107.     to cross-reference. Then I can put the line number version back in
  108.     interpreter, use TRON, or other debugging schemes I've devised.
  109.     Here's one I use -- I have this code in a file:
  110.     'Debug 
  111.     TempX = CSRLIN : TempY = POS(0)    ' Save current position
  112.     LOCATE 25,1            ' Go to bottom line
  113.     PRINT " >> Put the questioned variables here <<";
  114.     LOCATE TempX , TempY        ' Return to current position    
  115.  
  116.     When I have a roadblock bug, I insert this code, bracketing the
  117.     trouble area. This gives me a readout of the questioned variables on
  118.     the bottom line of the screen without messing up anything else.
  119.     It is more difficult to trace code without line numbers. Sometimes
  120.     I'll go into the code and simply put line numbers in front of each
  121.     line in the subroutine (by hand). Other times, I use QBX to put 
  122.     line numbers throughout the program.
  123.  
  124.     >> Epilog:
  125.         There are things I've yet to explore:
  126.             Calling assembly language subroutines
  127.             Using MAKE to handle compilation
  128.             Possibly setting up LIBS of subroutines for MAKE
  129.             The unknowns that YOU will tell me about
  130.  
  131.     ENJOY . . .
  132.  
  133.         David L. Poskie   Madison, WI
  134.  
  135. >>>>> Physical EOF QBSUB.TXT
  136.